import React, { Component } from 'react'
import { BrowserRouter as Router } from 'react-router-dom'
import { connect } from 'react-redux'
import { Layout} from 'antd'
import './App.css'
import PrivateRoute from './routes/PrivateRoute';
import { MainLayout, Dashboard, Users } from './components'
const { Content, Footer } = Layout
const {TopBar, SideBar, Bread} = MainLayout

const routes = [
  { 
    path: '/app/dashboard',
    component: Dashboard,
    exact: true,
    icon:'laptop',
    name: 'Dashboard'
  },
  { 
    path: '/app/users',
    component: Users,
    icon:'user',
    name: 'User'
  }
]
class App extends Component {
    state = {
        collapsed: false,
        menus: routes,
    };
    toggle = () => {
        this.setState({
          collapsed: !this.state.collapsed,
        });
    }
    render() {
      return (
        <Router>
        <Layout id="components-layout">
        <SideBar
          collapsed={this.state.collapsed}
          menus={this.state.menus}
          selectRoute={this.selectRoute}
        />
        <Layout >
            <TopBar className="header"
            collapsed={this.state.collapsed}
            toggle={this.toggle}
            selectRoute={this.selectRoute}
            />
            <Bread  menus={this.state.menus}/>
            <Content style={{margin:24}}>
               {routes.map((route, i) => (
                  <PrivateRoute
                  key={i}
                  path={route.path}
                  exact={route.exact}
                  component={route.component}
                  match={this.match}
                  authenticated={this.props.authenticated}
                />
              ))}
            </Content>
            <Footer className="footer"> Ant Design ©2017 Created by YueDuDay</Footer>
        </Layout>
        </Layout>
        </Router>
      );
    }
}
function mapStateToProps(state) {
  return {authenticated: state.auth.authenticated};
}
//const AuthenticationContainer = connect(mapStateToProps)(Authentication)
export default connect(mapStateToProps)(App);
